package com.zzz.system.mapper;

import com.mybatisflex.core.query.QueryColumn;
import com.mybatisflex.core.query.QueryWrapper;
import com.zzz.framework.config.mybatis.BaseMapperX;
import com.zzz.system.entity.Template;

import java.util.List;

import static com.mybatisflex.core.query.QueryMethods.column;

/**
 * 模板配置表 映射层。
 *
 * @author jian.li
 * @since 2023-10-23
 */
public interface TemplateMapper extends BaseMapperX<Template> {

    QueryColumn GROUP_CODE = column("group_code");
    QueryColumn CODE = column("code");

    default List<Template> findByGroupCode(String groupCode) {
        QueryWrapper query = QueryWrapper.create().where(
                GROUP_CODE.eq(groupCode)
        );
        return selectListByQuery(query);
    }

    default Template findByGroupCodeAndCode(String groupCode, String code) {
        QueryWrapper query = QueryWrapper.create().where(
                GROUP_CODE.eq(groupCode).and(CODE.eq(code))
        );
        return selectOneByQuery(query);
    }

}
